package com.briup.ptp.web.controller;



import com.briup.ptp.entity.Disease;
import com.briup.ptp.service.IllnessService;
import com.briup.ptp.utils.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.Banner;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Classname BannerController
 * @Description TODO
 * @Date 2023/12/26 15:52
 * @Created by zj
 * @Version v1.0.0
 */

@RestController
@RequestMapping("/illness")
@Api(tags = "病症管理模块")
public class IllnessController {

    @Autowired
    private IllnessService service;

    @GetMapping("/page")
    @ApiOperation("分页查询病症信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "病症名字", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页大小", required = true),
            @ApiImplicitParam(name = "pageNum", value = "当前页码", required = true),
    })
    public Object findIllness(String name, Integer pageSize, Integer pageNum) {
        PageInfo<Disease> illness = service.findIllness(name, pageSize, pageNum);
        return Result.success(illness);
    }


    @ApiOperation("新增/修改病症信息")
    @PostMapping("/saveOrUpdate")
    public  Result saveOrUpdateIllness(@RequestBody Disease disease){
        service.saveOrUpdateIllness(disease);
        return Result.success();
    }




    @ApiOperation("删除病症信息")
    @DeleteMapping("/deleteById/{id}")
    public Result deleDisease(@PathVariable Integer id){
        service.deleteDisease(id);
        return Result.success();

    }

    @ApiOperation("批量删除病症信息")
    @DeleteMapping("/deleteByIdAll")
    public Result  batchDeleteDisease(@RequestBody List<Integer> id){
        service.batchDeleteDisease(id);
        return Result.success();

    }


}
